/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tweetbotserver.server.message;

import java.util.HashMap;
import java.util.Map;
import tweetbotserver.robot.comms.BotMessage;

/**
 *
 * @author Mike
 */
public class TwitterMessageProcessor implements MessageProcessor<String> {

    
    public final static String FORWARD_COMMAND_NXT_CONFIRM = "forward - NXT";
    public final static String LEFT_COMMAND_NXT_CONFIRM = "left - NXT";
    public final static String RIGHT_COMMAND_NXT_CONFIRM = "right - NXT";
    
    public final static String FORWARD_TWEET = "I am going forward.";
    public final static String LEFT_TWEET = "I am going left.";
    public final static String RIGHT_TWEET = "I am going right.";
    
    
    private Map<String,String> tweetResponseMap = null;

    
    public TwitterMessageProcessor()
    {
        tweetResponseMap = new HashMap<String,String>();
        
        tweetResponseMap.put(FORWARD_COMMAND_NXT_CONFIRM, FORWARD_TWEET);
        tweetResponseMap.put(LEFT_COMMAND_NXT_CONFIRM, LEFT_TWEET);
        tweetResponseMap.put(RIGHT_COMMAND_NXT_CONFIRM, RIGHT_TWEET);
    }
    
    @Override
    public BotMessage parseData(String data) {
        BotMessage result = new BotMessage<String>(data);
        return result;

    }

    @Override
    public String parseBotMessage(BotMessage<String> botMessage) {
        
        String returnValue = "";
        String content = botMessage.getContent();
        
        content = content.trim();
        
        
        if(tweetResponseMap.containsKey(content))
        {
            returnValue = tweetResponseMap.get(content);
        }
        else
        {
            returnValue = content;
        }

        return returnValue;
        
        
    }
}
